<?php
/**
 * @ Fmash Top System
 * @ version: 3.0
 * @ author: i.coffee.smile@mail.com
 * @ date:2011-1-27
 * @ file:comment.php $17
 */

include_once 'class_mysql.php';
include_once 'ip.php';
include_once 'cookie.php';

if(!isset($_POST['cont']) && $_POST['cont'] =='')
{
	$message = rawurlencode('您需要输入内容！');
	header("location:error.php?error=$message");
	exit();
}

$comment = incheck($_POST['cont']);
$sid = incheck($_POST['id']);
$uid = $_COOKIE['UID'];
$username = $_COOKIE['Uname'];
$time = time();

if(strlen($comment)>500)
{
	$message = rawurlencode('您输入的字数太多了！');
	header("location:error.php?error=$message");
	exit();
}
else
{
	if($comment){
		$insert_comment1 = "INSERT INTO `$top_comment` (`cid` ,`sid` ,`uid`,`username` ,`time` ,`ip` ) ";
		$insert_comment1.= " VALUES (NULL , '$sid','$uid','$username','$time', '$ip');";
		mysql_query($insert_comment1);
		$cid = mysql_insert_id();
		$insert_comment2 = "INSERT INTO `$top_comment_content` (`cid`,`sid`,`content`)VALUES($cid,$sid,'$comment');";
		mysql_query($insert_comment2);
	}
	header("location: show.php?id=$sid");
}
?>

